<?php
    $servidor   = "localhost";
    $usuario    = "root";
    $password =  "gpi123";//gpi123
    $bd           = "ruta";
    
    $conexion = new mysqli($servidor, $usuario, $password, $bd);    
    
    if ($conexion->connect_errno)
    {
        $json['mensaje'] = "Connect failed: " . $conexion->connect_error;
        exit();
    }

    $conexion->autocommit("false");
    
    $select = "<select id='select_linea'>";
    $select.= "<option value='0'>Elegir L&iacute;nea</option>";
    
    if ($res = $conexion->query("SELECT `id`,`numero_linea` FROM `linea` ORDER BY `nombre_empresa`"))
    {
        while ($obj  = $res->fetch_object())
        {
            $select.= "<option value='" . $obj->id . "'>" . $obj->numero_linea . "</option>";
        }
    }
    else
    {
        $conexion->rollback();
        exit();
    }
    $select.= "</select>";
    $conexion->commit();
    $conexion->close();	    
    echo ($select);
?>